package com.kingstar.ceres.data.db;

import com.kingstar.ceres.data.db.mapper.CustomMapper;
import com.kingstar.ceres.data.handler.AbstractDataHandler;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class CurrencyDBHandler extends AbstractDataHandler {

    private final CustomMapper customMapper;


    public CurrencyDBHandler(CustomMapper customMapper) {
        this.customMapper = customMapper;
    }


    public void deleteByTableAndDate(String tableName, String dataDate){
        log.info("begin deleteByTableAndDate;tableName:{},dataDate:{}",tableName,dataDate);
        long row = customMapper.deleteByTableAndDate(tableName, dataDate);
        log.info("end deleteByTableAndDate;tableName:{},dataDate:{},row:{}",tableName,dataDate,row);
    }

    public void deleteByTableAndDateStr(String tableName, String dataDate){
        log.info("begin deleteByTableAndDateStr;tableName:{},dataDate:{}",tableName,dataDate);
        long row = customMapper.deleteByTableAndDateStr(tableName, dataDate);
        log.info("end deleteByTableAndDateStr;tableName:{},dataDate:{},row:{}",tableName,dataDate,row);
    }

    public void deleteAll(String tableName){
        log.info("begin deleteAll;tableName:{}",tableName);
        long row = customMapper.deleteByTable(tableName);
        log.info("end deleteAll;tableName:{},row:{}",tableName,row);
    }
}